package com.cy.pj.sys.dao;

import com.cy.pj.common.vo.Node;
import com.cy.pj.sys.pojo.SysMenu;
import com.cy.pj.sys.pojo.SysUserMenu;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * @author 张琪
 * @date 2020/11/14
 * @describe
 */

@Mapper
public interface SysMenuDao {
//    目前暂且不知道使用map的原因
    List<Map<String, Object>> findObjects();

    @Select("select id, name, parentId from sys_menus")
    List<Node> findZtreeMenuNodes();

    int insertObject(SysMenu sysMenu);

    int updateObject(SysMenu sysMenu);

    @Select("select count(*) from sys_menus where parentId = #{id}")
    int getChildCount(Integer id);

    @Delete("delete from sys_menus where id = #{id}")
    int deleteObject(Integer id);

//    @Select("select permission from sys_menus where id = #{id")
//    List<String> findPermissionById();

    /*基于菜单id获取菜单对应的授权标识*/
    List<String> findPermissionsByIds(List<Integer> menuIds);

    List<SysUserMenu> findMenusByIds(List<Integer> menuIds);
}
